#!/bin/sh
# 调整 /etc/ssh/sshd_config 文件内容
file=${1:-'/etc/ssh/sshd_config'}
sed -i -e "s/\#PermitRootLogin yes/PermitRootLogin yes/" \
sed -i -e "s/\#PermitRootLogin no/PermitRootLogin yes/" \
-e "s/\#PasswordAuthentication yes/PasswordAuthentication yes/" \
-e "s/\#PasswordAuthentication no/PasswordAuthentication yes/" \
-e "s/\#Port 22/Port 22/" \
-e "s/\#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/" \
-e "s/\#ListenAddress ::/ListenAddress ::/" "$file"
# 开启 sshd 服务
sudo service sshd start
# 检查 22 端口是否处于监听状态 yum -y install net-tools
if ! netstat -an | grep 22; then
echo 'install net-tools...'
yum -y install net-tools
fi
netstat -an | grep 22
exit 0